
#[derive(Debug, Clone, Copy)]
pub struct ConnFlag {
    pub seq: u8,
    pub flag: u8,
}

pub struct SeqMap<const CAP: usize> {
    items: [Option<ConnFlag>; CAP],
}

impl<const CAP: usize> SeqMap<CAP> {
    pub const fn const_new() -> Self {
        Self { items: [None; CAP] }
    }

    pub fn free(&mut self) -> Option<&mut ConnFlag> {
        for item in self.items.iter_mut() {
            
            if item.is_none() {
                *item = Some(ConnFlag { seq: 0, flag: 0 });
                return item.as_mut();
            }
        }
        None
    }

    pub fn clear(&mut self, seq: u8) {
        for item in self.items.iter_mut() {
            if let Some(v) = item {
                if v.seq == seq {
                    *item = None;
                }
            }
        }
    }

    pub fn flag(&mut self, seq: u8) -> Option<&mut ConnFlag> {
        for item in self.items.iter_mut() {
            if let Some(v) = item {
                if v.seq == seq {
                    return item.as_mut()
                }
            }
        }
        None
    }
}
